
$(document).ready(function () {	
	findPlanNoReportById();	
	$('#checkPlanBtn').click(function () {
		var ps=$("input[name='rst'][checked]").val();
		if(ps=="pass"){
			auditPlan(REPORTPASS);
		}else{
			auditPlan(REPORTBACK);
		}
	});	
});

function findPlanNoReportById(){	
	var timestamp = Date.parse(new Date());
	$.get("lzm/Plan_findPlanById.action?ts="+timestamp+"&PId="+getCookie(PId),null,findPlanNoReportByIdRst);
}

function findPlanNoReportByIdRst(data){
	var plan=data.tbPlan;
	$('#PName').text(plan.PName);
	$('#planType').text(plan.tbPlanType.ptName);
	$('#planGrade').text(plan.tbPlanGrade.pgName);
	$('#eventType').text(plan.tbEventType.etEventType);
	$('#planScope').text(plan.tbPlanScope.psName);
	$('#planRegion').text(plan.tbPlanRegion.prName);
	$('#PSummary').text(plan.PSummary);
	$('#PUnit').text(plan.PUnit);
	$('#PContractor').text(plan.PContractor);
	$('#PTime').text(plan.PTime.replace(/T/," "));
	$('#PVersion').text(plan.PVersion);	
}

/**
 * 作增加预案审批意见
 */
function auditPlan(ps){
	var url = 'lzm/SavePlan_auditPlan.action';
	if(ps == 3){
		ps = 4;
	}
	alert(ps);
	var params = {
			PId:getCookie(PId),
			POpinion:$('#POpinion').attr('value'),
			planStatus:ps
	}; 
	jQuery.post(url, params, auditPlanRst, 'json');
}

/**
 * 作审批预案回调函数
 */
function auditPlanRst(data){
	if(data.ajaxRst==SUCCESS){
		operateSucc("find_plan_no_record.jsp");
	}else{
		alert("添加预案审批意见失败");
	}
}